package com.ciaojian.core.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ciaojian.core.model.Setting;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 系统设置表 Mapper 接口
 * </p>
 *
 * @author Atlakyn
 * @since 2021-04-02
 */
public interface SettingMapper extends BaseMapper<Setting> {

    /**
     * 根据名称拿设置值
     *
     * @param name 名称
     * @return 值
     */
    @Select("SELECT value FROM sys_setting WHERE name = #{name} ")
    String getValue(@Param("name") String name);

    /**
     * 根据枚举拿设置值
     *
     * @param name 枚举
     * @return 值
     */
    @Select("SELECT value FROM sys_setting WHERE name = #{name} ")
    Object getValueAsObject(@Param("name") String name);

    /**
     * 根据枚举拿设置的值
     *
     * @param name 枚举
     * @return integer 值
     */
    @Select("SELECT value FROM sys_setting WHERE name = #{name} ")
    Integer getValueAsInt(@Param("name") String name);
}
